﻿var formatPriority = function (elCell, oRecord, oColumn, sData) {
    var showText;
    if (sData == "1") {
        showText = "<font color='red'>特急</font>";
    } else if (sData == "2") {
        showText = "<font color='green'>紧急</font>";
    } else {
        showText = "普通";
    }
    elCell.innerHTML = showText;
}

var formatShow = function (elCell, oRecord, oColumn, sData) {
    var WorkFlowInstanceId = oRecord.getData("WorkFlowInstanceId");
    var workflowId = oRecord.getData("WorkFlowId");
    var taskCaption = oRecord.getData("FlowCaption");
    var url = '"' + "../../Crm/BasePages/WorkflowMap.aspx?WorkFlowInstanceId=" + WorkFlowInstanceId + "&workflowId=" + workflowId + '"';
    var title;
    var taskTitle = "";
    if (taskCaption != undefined) {
        title = '"' + taskCaption + '流程图"';
    }
    else {
        title = '"' + taskTitle + '流程图"';
    }
    elCell.innerHTML = "<a href='javascript:transForForm(" + title + "," + url + ")'>流程图</a><br />";
}
var transForForm = function (title, url) {
    parent.addTabs(title, url);
    parent.NeedRefreshPage = this;
}

var formatCaption = function (elCell, oRecord, oColumn, sData) {
    var WorkTaskInstanceId = oRecord.getData("WorkTaskInstanceId");
    var OperatorInstanceId = oRecord.getData("OperatorInstanceId");
    var url = '"' + "../../Crm/BasePages/WorkTaskCtrlPage.aspx?WorkTaskInstanceId=" + WorkTaskInstanceId + "&OperatorInstanceId=" + OperatorInstanceId + '"';
    var title = '"' + sData + '"';
    elCell.innerHTML = "<a href='javascript:transForForm(" + title + "," + url + ")'>" + sData + "</a><br />";
}
var formatWorkFlow = function (elCell, oRecord, oColumn, sData) {
    var WorkTaskInstanceId = oRecord.getData("WorkTaskInstanceId");
    var WorkFlowInstanceId = oRecord.getData("WorkFlowInstanceId");
    var LogType = oRecord.getData("LogType");

    var url = '"' + "../../WorkFlow/BasePages/ErrorLogs.aspx?WorkTaskInstanceId=" + WorkTaskInstanceId + "&WorkFlowInstanceId=" + WorkFlowInstanceId + "&logType=" + LogType + '"';
    var title = '"' + sData + '"';
    elCell.innerHTML = "<a href='javascript:transForForm(" + title + "," + url + ")'>" + sData + "</a><br />";
}
var formatFlowList = function (elCell, oRecord, oColumn, sData) {
    var WorkFlowInstanceId = oRecord.getData("WorkFlowInstanceId");
    var workflowId = oRecord.getData("WorkFlowId");
    var workFlowNo = oRecord.getData("WorkFlowNo");
    var taskCaption = oRecord.getData("FlowCaption");
    var url = '"' + "../../WorkFlow/ErrorLogs.aspx?WorkFlowInstanceId=" + WorkFlowInstanceId + "&Statues=1" + '"';
    var title;
    var taskTitle = "";
    if (taskCaption != undefined) {
        title = '"详细错误内容"';
    }
    else {
        title = '"详细错误内容"';
    }
    elCell.innerHTML = "<a href='javascript:transForForm(" + title + "," + url + ")'>详细错误内容</a><br />";
}

//自动义双击方法
function CustomDbClick() { }
//自动义删除方法
var fnCustomDelete = function () {
    //alert("2");
    var list = this.mDataTable.getRecordSet()._records;
    var WorkTaskInstanceId = list[0]._oData["WorkTaskInstanceId"];
    var WorkFlowInstanceId = list[0]._oData["WorkFlowInstanceId"];
    var logType = list[0]._oData["LogType"];
    if (confirm("是否处理此异常流程?")) {
       var SaveUrl = "../../WorkFlow/ErrorLogs.aspx?WorkTaskInstanceId=" + WorkTaskInstanceId + "&WorkFlowInstanceId=" + WorkFlowInstanceId + "&logType=" + logType + "";
        //var SaveUrl = '"' + "../../WorkFlow/ErrorLogs.aspx?WorkTaskInstanceId=" + WorkTaskInstanceId + "&WorkFlowInstanceId=" + WorkFlowInstanceId + "&logType=" + LogType + '"';
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText.substring(0,1);
                   
                    if (str == "1") {
                        alert("数据处理成功");
                    }
                    else {
                        alert(res.responseText + "\n" + "数据处理失败!");
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
}